﻿Imports System
Imports System.IO
Imports System.Data.OleDb
Imports System.Data
Imports System.Net.Mail

Namespace Arwani
    Partial Class promo
        Inherits System.Web.UI.Page
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Call setPageSEOInformation()
        End Sub

        Public Sub setPageSEOInformation()
            Dim thisURL As String = Request.Url.AbsoluteUri.Substring(Request.Url.AbsoluteUri.LastIndexOf("/") + 1)
            thisURL = thisURL.Substring(0, thisURL.IndexOf(".aspx") + 5)
            Dim keyword As New HtmlMeta
            keyword.Name = "keyword"


            Dim description As New HtmlMeta
            description.Name = "Description"


            Dim arwCon As New ArwaniController
            Dim strQ As String = "select * from AddSEO where PageName='" & thisURL.ToLower() & "'"
            Dim dtTable As DataTable = arwCon.ExecuteQuery(strQ)
            Dim iCount As Integer = 0
            If dtTable.Rows.Count > 0 Then
                If Not IsDBNull(dtTable.Rows(0)("Title")) Then Page.Title = dtTable.Rows(0)("Title")
                If Not IsDBNull(dtTable.Rows(0)("keywords")) Then keyword.Content = dtTable.Rows(0)("keywords")
                If Not IsDBNull(dtTable.Rows(0)("Description")) Then description.Content = dtTable.Rows(0)("Description")
            End If

            Page.Header.Controls.Add(keyword)
            Page.Header.Controls.Add(description)
        End Sub

        Protected Sub lnkSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkSend.Click
            Dim strMessage As String = ""
            strMessage = "Following information has been sent in the Promo form<br>"
            strMessage &= "Contact Name : " & Me.txtContactName.Text & "<Br>"
            strMessage &= "Company Name : " & Me.txtCompanyName.Text & "<Br>"
            strMessage &= "Office phone no. : " & Me.txtOficePhone.Text & "<Br>"
            strMessage &= "Mobile phone no. : " & Me.txtMobilePhone.Text & "<Br>"


            'Try
            MailHelper.SendMailMessage(Me.txtEmail.Text, "niteshguleria@nascenture.com", "", "", "Promo Enquiry - Arwani Trading Website", strMessage)
            'Catch ex As Exception
            'Response.Redirect("http://www.google.com")
            'End Try
            Me.lblErrorMessage.Visible = True
            Me.txtCompanyName.Text = String.Empty
            Me.txtContactName.Text = String.Empty
            Me.txtOficePhone.Text = String.Empty
            Me.txtMobilePhone.Text = String.Empty
            Me.txtEmail.Text = String.Empty


        End Sub
    End Class
End Namespace